package main

import (
	"fmt"
	"io"
	"strings"
)

func main() {
	data, err := ReadFrom(strings.NewReader("yuekinger"), 6)
	// data, err := ReadFrom(os.Stdin, 6)
	//
	if err == nil {
		fmt.Printf("data: %v %s\n", data, string(data))
	}
}

func ReadFrom(reader io.Reader, num int) ([]byte, error) {
	p := make([]byte, num)
	n, err := reader.Read(p)
	if n > 0 {
		return p[:n], nil
	}
	return p, err
}
